using System;
using System.Collections.Generic;
using System.Text;
using ZuDoKu.Controls;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace ZuDoKu.Screens
{
    class Splash : Screen
    {
        bool fadingIn = true;
        const double FadeTime = 1400;

        public Splash()
        {
            Texture2D background = Game.Content.Load<Texture2D>(@"Screens\Splash\background");

            Texture = background;
            Transparency = 0;
        }

        public override void Update(GameTime gameTime)
        {
            if (fadingIn)
            {
                Transparency = (int)((gameTime.TotalGameTime.TotalMilliseconds / FadeTime) * 255d);
                
            }
            else
            {
                Transparency = 255 - (int)(((gameTime.TotalGameTime.TotalMilliseconds-FadeTime) / FadeTime) * 255d); 
            }

            if (fadingIn && gameTime.TotalGameTime.TotalMilliseconds > FadeTime)
            {
                fadingIn = false;
            }

            if (gameTime.TotalGameTime.TotalMilliseconds > FadeTime*2)
            {
                OnChange(new MainMenu());
            }

            base.Update(gameTime);
        }
    }
}